<?php

/**
 * 
 * Deposer une annonce
 * @author Redouane
 *
 */
class ContactSellerForm extends AdsForm{
    public function configure(){
            $this->useFields(array('title'));
            $this->widgetSchema['seller_email'] = new sfWidgetFormInputHidden();   
            $this->widgetSchema['title'] = new sfWidgetFormInputHidden();   
            $this->widgetSchema['bayer_name'] = new sfWidgetFormInput();
            $this->widgetSchema['bayer_email'] = new sfWidgetFormInput();
            $this->widgetSchema['message'] = new sfWidgetFormTextarea();
	    
            /* Validators */
            $this->validatorSchema['bayer_name']    = new sfValidatorString(array('required' => true));
            $this->validatorSchema['bayer_email']   = new sfValidatorEmail(array('required' => true));
            $this->validatorSchema['message']       = new sfValidatorString(array('required' => true));
            $this->validatorSchema['seller_email']  = new sfValidatorString();
            
            /* Schema */
            $this->validatorSchema['bayer_name']->setMessage('required', 'Veuillez renseigner votre nom');
            $this->validatorSchema['message']->setMessage('required', 'Veuillez renseigner votre message');
	
            $this->validatorSchema['bayer_email']->setMessage('required', 'Veuillez renseigner votre email');
            $this->validatorSchema['bayer_email']->setMessage('invalid', 'Email invalide');
	    
            $this->widgetSchema->setLabels(
		array(
			'bayer_name'    => 'Votre nom',
			'bayer_email'   => 'Votre Email',
                        'message'       => 'Message'
            ));
	
            $this->setDefaults( array(
                'seller_email'  => $this->getObject()->Seller->email,
                'title'         => $this->getObject()->title,
            ));
            
            $this->widgetSchema->setNameFormat('contactSeller[%s]');
            $this->widgetSchema->setFormFormatterName('div');
            $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('messages');
    }
}